//
// Created by Jisam on 2024/8/8 14:11.
// 14点47分 AC 看错题目以为x y 是障碍 实则为起点
// solve P1443 马的遍历
#include <bits/stdc++.h>

#define PSI pair<string,int>
#define PII pair<int,int>
#define PDI pair<double,int>
#define PDD pair<double,double>
#define VVI vector<vector<int>>
#define VI vector<int>
#define VS vector<string>

#define PQLI priority_queue<int, vector<int>, less<int>>
#define PQGI priority_queue<int, vector<int>, greater<int>>
using u32 = unsigned;
using i64 = long long;
using u64 = unsigned long long;

using namespace std;
int horse[][2] = {{1,  2},
                  {2,  1},
                  {-1, 2},
                  {2,  -1},
                  {1,  -2},
                  {-2, 1},
                  {-1, -2},
                  {-2, -1},};

void bfs(int i, int j, int n, int m, vector<vector<int>> &a, vector<vector<int>> &vis) {
    queue<PII > q;
    q.push({i, j});
    vis[i][j] = 1;
    a[i][j] = 0;
    while (!q.empty()) {
        auto [x, y] = q.front();
        q.pop();
//        cout << x << " " << y << "\n" ;

        for (int k = 0; k < 8; k++) {
            int tx = x + horse[k][0];
            int ty = y + horse[k][1];

            if (tx >= 0 && ty >= 0 && tx < n && ty < m && vis[tx][ty] == 0 ) {
//                cout << tx << " " << ty <<" \n";
                q.push({tx, ty});
                vis[tx][ty] = 1;
                a[tx][ty] = a[x][y] + 1;
            }
        }
    }
}

void solve() {
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    vector a(n, vector<int>(m, 0));
    vector vis(n, vector<int>(m, 0));
    bfs(x-1, y-1, n, m, a, vis);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (vis[i][j] == 0) cout << left << setw(5) << "-1";
            else cout << left << setw(5) << a[i][j];
        }
        if(i != n -1) cout << "\n";
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1;
//    cin >> T;
    while (T--) solve();
//    cout << "\n"[];
    return 0;
}